#include <cstdio>
#include <cstring>

int answer[22];
int hash[22];

int n;
int prime[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 27, 41};

bool prime_judge(int x);

void check_answer();

void DFS(int num);

bool prime_judge(int x) {
    for (int i = 0; i < 13; ++i) {
        if (prime[i] == x)
            return true;
    }
    return false;
}

int main(int argc, char const *argv[]) {
    int case_num = 0;
    while (scanf("%d", &n) != EOF) {
        case_num++;
        for (int i = 0; i < 22; ++i)
            hash[i] = false;
        answer[1] = 1;
        printf("Case %d:\n", case_num);
        hash[1] = true;
        DFS(1);
        printf("\n");
    }
    return 0;
}

void check_answer() {
    if (!prime_judge(answer[n] + answer[1]))
        return;
    for (int i = 1; i <= n; ++i) {
        if (i != 1)
            printf(" ");
        printf("%d", answer[i]);
    }
    printf("\n");
}

void DFS(int num) {
    if (num > 1) {
        if (!prime_judge(answer[num] + answer[num - 1]))
            return;
    }
    if (num == n) {
        check_answer();
        return;
    }
    for (int i = 2; i <= n; ++i) {
        if (!hash[i]) {
            hash[i] = true;
            answer[num + 1] = i;
            DFS(num + 1);
            hash[i] = false;
        }
    }
}